from Tkinter import *
from FrameSeriesStatus import FrameSeriesStatus
from FrameSeriesList import FrameSeriesList
#from AnimatedImageControl import AnimatedImageControl

class FrameMenu(Frame):

    _binding_button_content = None
    _menu_buttons = []
    _default_menu_button = None
    _onMenuChange = None
    
    def __init__(self,master, onMenuChange):
        Frame.__init__(self,master)

        self._binding_button_content = {'Listado de series':FrameSeriesList(master),
                                        'Estado de series':FrameSeriesStatus(master)}
#                                        'img':AnimatedImageControl(master, ["./img/perro/dog001.gif",
#                                                                                       "./img/perro/dog002.gif",
#                                                                                       "./img/perro/dog003.gif",
#                                                                                       "./img/perro/dog004.gif",
#                                                                                       "./img/perro/dog005.gif",
#                                                                                       "./img/perro/dog006.gif",
#                                                                                       "./img/perro/dog007.gif"]) }
        self._default_menu_button = 'Listado de series'
#        self._default_menu_button = 'img'

        self._onMenuChange = onMenuChange

        self.set_menu()

    def set_menu(self):
        a = 1
        for b in self._binding_button_content.keys():
            button = Button(self, text=b, command=lambda id=b: self.menu_button_click(id))
            button.grid(column=0, row=a, sticky=W+N)
            self._menu_buttons.append(button)
            a = a + 1
        if not(self._default_menu_button is None):
            self.menu_button_click(self._default_menu_button)

    def menu_button_click(self, button):
        self._onMenuChange(self._binding_button_content[button])
